package com.laivi.basic.model.datastruct;

import java.util.LinkedList;
import java.util.List;

/**
 * @author laivi.zhu@gmail.com
 * @date 2014-6-16
 * description:
 */
public class Stack<T> {

	private int size;
	
	private List<T> stack;

	public Stack(int size) {
		super();
		this.size = size;
		stack=new LinkedList<T>();
	}

	public Stack() {
		super();
	}
	
	public void push(T t){
		if(stack.size()<size|| size==0){
			stack.add(t);
		}
	}
	
	public T pull(){
		if(stack.size()==0) return null;
		return stack.get(stack.size()-1);
	}
	
	public void clear(){
		stack.clear();
	}
	
	public int size(){
		return stack.size();
	}
	
	public boolean contains(T t){
		return stack.contains(t);
	}

	public void setSize(int size) {
		this.size = size;
	}
}
